#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
    int halveArray(vector<int> &nums)
    {
        int count = 0;
        double sum1{0};
        priority_queue<double> q;
        for (auto x : nums)
        {
            q.push(x);
            sum1 += x;
        }
        double sum2 = sum1;
        while (sum2 > sum1 / 2)
        {
            auto x = q.top();
            x /= 2;
            q.pop();
            sum2 -= x;
            q.push(x);
            ++count;
        }
        return count;
    }
};